#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys

print sys.getdefaultencoding()

reload(sys)
sys.setdefaultencoding('utf8')  # 原始编码为ascii，转换为utf-8


def encode1():  # 对于指定的编码格式，如utf-8，encode和decode对原始结果无影响
    name = "周星星"
    print name.encode()
    print name.decode()


def encode2():
    name = "周星星"
    print name.decode('utf-8')[0] # 字符串自动转list，x[number]获取指定结果


if __name__ == '__main__':
    print sys.getdefaultencoding()
    print "-" * 60
    encode1()
    print "-" * 60
    encode2()
